--[[ 编码: hh-mobox-009 名称: 货位状态 作者:SGX 日期:2024-11-27 函数: GenChartJson 功能: 叠柱状图 更改记录: --]] json = require("json") mobox = require("OILua_JavelinExt") m3 = require( "oi_base_mobox" ) function GenChartJson(strLuaDEID) local nRet, strRetInfo --[[ 标题颜色 ]] local strTitle = "巷道货位状态" --[[ 文字颜色 ]] local strColor = "#fff" --[[ 柱状图柱子名称,对应 series 下name ]] local tabLegendData = {'有货', '无货'} --[[ X轴数据 从左向右 ]] local tabXAxis = {'1', '2', '3', '4', '5', '6', '7', '8'} --[[ Y轴 最上方显示文字 ]] local strYAxisName = "货位数量" --[[ 满仓颜色 ]] local strMCColor = '#45A048' --[[ 空仓颜色 ]] local strKCColor = '#FE9700' --[[ 柱状图数据 对应X轴数据 ]] --[[ 满仓 ]] -- local tabSeriesMCData = {} -- for i = 1 ,8 do -- local strCondition = "N_ROADWAY = "..i.." AND N_CURRENT_NUM = 1" -- nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Location", strCondition) -- if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "getDataObjCount 失败! " .. strRetInfo) end -- tabSeriesMCData[i] = lua.StrToNumber(strRetInfo) -- end -- --[[ 空仓 ]] -- local tabSeriesKCData = {} -- for i = 1 ,8 do -- local strCondition = "N_ROADWAY = "..i.." AND N_CURRENT_NUM = 0" -- nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Location", strCondition) -- if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "getDataObjCount 失败! " .. strRetInfo) end -- tabSeriesKCData[i] = lua.StrToNumber(strRetInfo) -- end --[[ 满仓 ]] local tabSeriesMCData = {400, 360, 350, 340, 330, 325, 324, 300} --[[ 空仓 ]] local tabSeriesKCData = {180, 170, 160, 150, 130, 120, 110, 100} local option = { title = { text = strTitle, left = 20, textStyle = { color = strColor }, top = 10 }, legend = { data = tabLegendData, textStyle = { color = strColor }, top = 10 }, grid = { left = '5%', right = '5%', bottom = '5%', top = '22%', containLabel = true }, xAxis = { type = 'category', data = tabXAxis, axisLabel = { textStyle = { color = strColor } -- , -- fontSize = 16, -- interval = 0 }}, yAxis = { type = 'value', nameTextStyle = { color = strColor }, axisLabel = { textStyle = { color = strColor } } }, series = {{ name = '有货', type = 'bar', stack = 'total', label = { show = true }, color = strMCColor, data = tabSeriesMCData }, { name = '无货', type = 'bar', stack = 'total', label = { show = true }, color = strKCColor, data = tabSeriesKCData }} } local action = {} action[1] = { action_type = "chart", value = { graphicType = "echart", title = { text = strTitle, align = "center", color = "#515a6e", font = "微软雅黑", fontSize = 12 }, option = option } } lua.Debug(strLuaDEID, debug.getinfo(1), "action! ", action) nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action)) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction) end end